$(function () {
    var $tags = $('#acc-tab').find('a');
    window.mySwipe = new Swipe(document.getElementById('slider'), {
        continuous: false,
        disableScroll: false,
        stopPropagation: false,
        callback: function(index) {
            $tags.eq(index).addClass('tag-on')
                .siblings('a').removeClass('tag-on');
        },
        transitionEnd: function(index, elem) {}
    });
    $tags.eq(0).click(function (e) {
        mySwipe.prev();
        e.preventDefault();

    });
    $tags.eq(1).click(function (e) {
        mySwipe.next();
        e.preventDefault();
    });
    $('#tab-bar').remove();


    $('.get-more').click(function () {
        var pageNum = $('#page_num').val();
        console.log(pageNum);
        var url = "/account/member/user_wallet/" + (parseInt(pageNum) + 1);
        var pdata = {};
        var _this = $(this);
        Magiclamp.listLoad();
        Magiclamp.mcAjax(url, "post", pdata, function (dataBack) {
                var html = '';
                if (dataBack.data.vmoney) {
                    dataBack.data.vmoney.forEach(function (v) {
                        html +='<li>';
                        html +='<div class="his-info">';
                        html +='<p class="type">'+v.mytypename+'</p>';
                        html +='<p class="date">'+v.stime+'</p>';
                        html +='</div>';
                        if(v.myvalueout > 0){
                            html += '<div class="his-sum minus">-';
                            html += Magiclamp.amountInto(v.myvalueout);
                            html +='</div>';
                        }
                        if(v.myvalue > 0){
                            html += '<div class="his-sum plus">';
                            html += Magiclamp.amountInto(v.myvalue);
                            html +='</div>';
                        }
                        html +='</li>';
                    })
                }
                $('#vm_list').append(html);
                $('#page_num').val(dataBack.data.page);
                Magiclamp.listLoadGet($('#get_more_vm'), '加载更多', 'auto');
                if (parseInt(pageNum) == $('#page_num').val() || dataBack.data.vmoney.length != $('#page_limit').val()) {
                    Magiclamp.listLoadGet($('#get_more_vm'), '已加载全部', 'none');
                }

            var html = '';
            if (dataBack.data.mmoney) {
                dataBack.data.mmoney.forEach(function (v) {
                    html +='<li>';
                    html +='<div class="his-info">';
                    html +='<p class="type">'+v.mytypename+'</p>';
                    html +='<p class="date">'+v.stime+'</p>';
                    html +='</div>';
                    if(v.myvalueout > 0){
                        html += '<div class="his-sum minus">-';
                        html += Magiclamp.amountInto(v.myvalueout);
                        html +='</div>';
                    }
                    if(v.myvalue > 0){
                        html += '<div class="his-sum plus">';
                        html += Magiclamp.amountInto(v.myvalue);
                        html +='</div>';
                    }
                    html +='</li>';
                })
            }
            $('#mm_list').append(html);
            $('#page_num').val(dataBack.data.page);
            Magiclamp.listLoadGet($('#get_more_mm'), '加载更多', 'auto');
            if (parseInt(pageNum) == $('#page_num').val() || dataBack.data.mmoney.length != $('#page_limit').val()) {
                Magiclamp.listLoadGet($('#get_more_mm'), '已加载全部', 'none');
            }

                Magiclamp.imgSrc();
            }, function (databack) {
                Magiclamp.listLoadGet(_this, databack.message, 'none');
            }, true
        );
        return false;
    });
})